<?php session_start();
include ("../model/connect.php");
include ('../model/currentSemester.php');
include ("../model/Staff/class-trainningprogram.php");
include ("../model/Staff/class-trainningitem.php");
include ('../control/student-proc.php');

$idtrainningpro = $_POST['idtrainningpro'];
$checkid = $_POST['checkid'];
$trnppro = new TrainningProgram();
$trnpitem = new TrainningItem();

if(empty($checkid))
  {	
    $_SESSION["openclass-error"] = "<script>alert(\"Bạn chưa chọn môn nào để mở !!!\");</script>";
    header("location:http:/educational/staff-index.php?p=staff-list-course&idtrainningpro={$idtrainningpro}");
  }
  else
  {
    $N = count($checkid);
    for($i=0; $i < $N; $i++)
    {
		$yearChoossen = $_POST['class'.$checkid[$i]];
		$semester = calStudentSemester($currentSemester,$currentYear,$yearChoossen) + 1;
      	$trnpitem->addTrainningItem($idtrainningpro,$checkid[$i],$semester,$trnppro);
    }
     mysql_close($conn);
     header("location:http:/educational/staff-index.php?p=staff-list-trainning-program");
  }
?>